<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>文件上传</title>
		<cw:base></cw:base>
		<script type="text/javascript">
			function submitFormWithFile(){
				Wonders.utils.formSubmit(Ext.getCmp("submitFileBtn"), 'formWithFile',
					function(form,action){
						var json = Ext.decode(action.response.responseText).result[0];
						if(json.flag==0){
							Wonders.Msg.error(json.msg,'错误',function(){Ext.getCmp('submitFileBtn').enable();__WSSIP_GENERATE_GUID__();});
						}else{
							Wonders.Msg.info(json.msg,'提示',function(){Ext.getCmp('submitFileBtn').enable();__WSSIP_GENERATE_GUID__();});
						}
						return false;
					},
					null,
					function(form,action){
						Ext.getCmp('submitFileBtn').enable();
						__WSSIP_FAILURE_HANLDER__(form,action);
						return false;
					}
				);
			}
		</script>
	</head>
	<body>
		<ul>
			<li>
				<b> 通过allowFileType设置允许上传的文件类型，enableMulti设置是否可以上传多个文件 </b>
			</li>
		</ul>
		<br/>
		<cw:form id="formWithFile" ajax="true" url="${pageContext.request.contextPath}/demoform/upload!doUpload.action" waitMsg="提交中..." fileUpload="true">
			<table>
				<tr>
					<td>
						<cw:upload id="fileData" property="fileData" enableMulti="true" fileCount="2" allowFileType="*.xls|*.xlsx" 
							allowFileTypeDesc="只允许上传Excel" required="true" label="附件" width="360" />
					</td>
				</tr>
				<tr><td><cw:button id="submitFileBtn" text="上传文件" onclick="submitFormWithFile();" /></td></tr>
			</table>
		</cw:form>
		<cw:theme></cw:theme>
		<script type="text/javascript">
			Ext.onReady(function(){
				resetHeight("fileFrame");
			})
		
			function resetHeight(frame) {
				var ifm = parent.document.getElementById(frame);
				var obj = document.body;
				var oStyle = obj.currentStyle? obj.currentStyle : window.getComputedStyle(obj, false);
				var initHeight = parseInt(document.body.clientHeight+parseInt(oStyle["margin-top"])+parseInt(oStyle["margin-bottom"]));
				ifm.height = parseInt(initHeight);
			}
		</script>
	</body>
</html>
